﻿using System;

namespace UniRx.Operators
{
	// Token: 0x02000313 RID: 787
	internal class SynchronizedObserver<T> : IObserver<T>
	{
		// Token: 0x0600107B RID: 4219 RVA: 0x0004C00C File Offset: 0x0004A40C
		public SynchronizedObserver(IObserver<T> observer, object gate)
		{
			this.observer = observer;
			this.gate = gate;
		}

		// Token: 0x0600107C RID: 4220 RVA: 0x0004C024 File Offset: 0x0004A424
		public void OnNext(T value)
		{
			object obj = this.gate;
			lock (obj)
			{
				this.observer.OnNext(value);
			}
		}

		// Token: 0x0600107D RID: 4221 RVA: 0x0004C068 File Offset: 0x0004A468
		public void OnError(Exception error)
		{
			object obj = this.gate;
			lock (obj)
			{
				this.observer.OnError(error);
			}
		}

		// Token: 0x0600107E RID: 4222 RVA: 0x0004C0AC File Offset: 0x0004A4AC
		public void OnCompleted()
		{
			object obj = this.gate;
			lock (obj)
			{
				this.observer.OnCompleted();
			}
		}

		// Token: 0x040009AE RID: 2478
		private readonly IObserver<T> observer;

		// Token: 0x040009AF RID: 2479
		private readonly object gate;
	}
}
